<?php

class App_Methods_Data_ApplicationData {
	
	public $label;
	public $description;
	public $type;
	public $value;
	public $important;
	
	public function __construct(ApplicationDataDefs $applicationDataDef) {
		$lang = Core_Core::getInstance()->getApp()->lang;
		if ($lang == 'en') {
			$this->label = $applicationDataDef->getLabelEn();
			$this->description = $applicationDataDef->getDescriptionEn();
		}
		else {
			$this->label = $applicationDataDef->getLabel();
			$this->description = $applicationDataDef->getDescription();
		}
		$this->type = $applicationDataDef->getValueType();
		if ($applicationDataDef->getUserApplicationDatas()->getFirst() instanceof UserApplicationData) {
			$data = $applicationDataDef->getUserApplicationDatas()->getFirst();
			$this->value = $data->getValue();
			$this->important = (bool)$data->getImportant();
		}
		else {
			$this->value = $applicationDataDef->getDefaultValue();
			$this->important = false;
		}
	}
	
}